

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;

namespace DataLayer
{
	public class datLanguages
	{
		public datLanguages()
		{
		}
		
		#region  Code Factory Generated Methods
		public void DeleteLanguagesByLanguageId(entLanguages parEntLanguages, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLanguageId",parEntLanguages.LanguageId);
			parDbConnector.ExecuteNonQuery("DeleteLanguagesByLanguageId",insDbParamCollection);
		}
		public void InsertLanguages(entLanguages parEntLanguages, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLanguageName",parEntLanguages.LanguageName);
			insDbParamCollection.Add("@pLanguageCulture",parEntLanguages.LanguageCulture);
			insDbParamCollection.AddOutput("@pLanguageId",DbType.Int32);
			parDbConnector.ExecuteNonQuery("InsertLanguages",insDbParamCollection);
			parEntLanguages.LanguageId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
		}
		public void UpdateLanguagesByLanguageId(entLanguages parEntLanguages, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLanguageId",parEntLanguages.LanguageId);
			
			insDbParamCollection.Add("@pLanguageName",parEntLanguages.LanguageName);
			insDbParamCollection.Add("@pLanguageCulture",parEntLanguages.LanguageCulture);
			parDbConnector.ExecuteNonQuery("UpdateLanguagesByLanguageId",insDbParamCollection);
		}
		public DataTable SelectLanguages(DbConnector parDbConnector)
		{
			
			return parDbConnector.ExecuteDataTable("SelectLanguages",null);
		}
		public void SelectLanguagesByLanguageId(entLanguages parEntLanguages, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLanguageId",parEntLanguages.LanguageId);
			DataTable insDataTable = new DataTable();
			insDataTable = parDbConnector.ExecuteDataTable("SelectLanguagesByLanguageId",insDbParamCollection);
			if (insDataTable.Rows.Count>0)
			{
				if (insDataTable.Rows[0]["LanguageId"]!=DBNull.Value)
				{
					parEntLanguages.LanguageId = Convert.ToInt32(insDataTable.Rows[0]["LanguageId"]);
				}
				if (insDataTable.Rows[0]["LanguageName"]!=DBNull.Value)
				{
					parEntLanguages.LanguageName = insDataTable.Rows[0]["LanguageName"].ToString();
				}
				if (insDataTable.Rows[0]["LanguageCulture"]!=DBNull.Value)
				{
					parEntLanguages.LanguageCulture = insDataTable.Rows[0]["LanguageCulture"].ToString();
				}
			}
		}
		public bool CheckLanguagesExists(entLanguages parEntLanguages, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLanguageId",parEntLanguages.LanguageId);
			
			insDbParamCollection.Add("@pLanguageName",parEntLanguages.LanguageName);
			object result = parDbConnector.ExecuteScalar("CheckLanguagesExists",insDbParamCollection);
			if (result == null || result==DBNull.Value)
			{
				return false;
			}
			else
			{
				return (Convert.ToInt32(result)!=0);
			}
		}
		#endregion
	}
}